home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp95 / tc2exm.doc < prev    next >
Text File  |  1995-03-31  |  6KB  |  110 lines

  1. ***********************************************************************
  2. Using Borland C to create .EXM files for the HP95LX
  3. ***********************************************************************
  4.  
  5. Yes, believe it or not, you can use Borland tools to create System
  6. Manager compliant applications for the 95LX!  Although this has been
  7. tested only with Turbo C++ and Borland C++, it should work for the whole
  8. Turbo C family.  The two basic problems to work around are the startup
  9. code and the E2M program.
  10.  
  11. (NOTE: TKERNEL is a PC TSR that provides the SysMgr services on the PC,
  12.   in a non-task-swapping environment, allowing you to debug your program
  13.   on a PC, using standard PC debuggers.  Unfortunately, this program is
  14.   property of Lotus Corporation, which as decided NOT to allow its
  15.   distribution to anyone EXCEPT for ISV's that have been accepted into
  16.   the supported ISV program.  However, the rest of this note (regarding
  17.   creating .EXM files for use on the HP 95LX, is applicable even if you
  18.   DON'T have access to TKERNEL.)
  19.  
  20. To create programs to run under TKERNEL, you shouldn't need to do
  21. anything special.  Just make sure to link in CSVC.OBJ (included in the
  22. ISV kit and on the HP BBS) so the c_service routines are defined.  Since
  23. you will probably want to use the Turbo C integrated environment, MAKE
  24. SURE YOU INCLUDE any #defines that the Microsoft make file may jam in
  25. before you compile.  BOXES.C is an example of this: it defines TKERNEL
  26. from the make file for the tkernel file, but does not for the EXM file.
  27. If you run non-TKERNEL code under TKERNEL you will almost certainly have
  28. problems (eg. Divide overflow) since TKERNEL doesn't support the full
  29. set of System Manager functions.
  30.  
  31. STEP 1
  32. ------
  33. To create .EXM programs for the System Manager, it gets a little more
  34. complicated.  First of all, you need to trick Turbo C into leaving out
  35. its own startup code and including CRT0.OBJ (also included in the ISV
  36. kit / HP BBS).    CRT0 is just about the minimum that is needed upon
  37. startup so the program doesn't do all kinds of funny stuff on the 95
  38. that isn't supported.  To do this, go to the directory that you keep
  39. your CRT0.OBJ and CSVC.OBJ files (assume it is \HP95\TOOLS) , and copy
  40. CRT0.OBJ into a new file, C0S.OBJ.    C0S.OBJ is the file that Turbo C
  41. uses for small model startup code, so we're just replacing it.
  42.  
  43. Now go into the integrated environment under Options/Directory/Libraries,
  44. and insert the directory name \HP95\TOOLS; (or whatever you use) *in
  45. front* of what currently lies there (so it will find our "fake" C0S
  46. first). Also remember to link in CSVC.OBJ as well (just add it to your
  47. project file). Now you should be able to compile your SysMgr app with no
  48. problems. (Other helpful hints on compiling:  Remember under small model
  49. code only, no floating point code, and don't link in the graphics
  50. library.)
  51.  
  52. STEP 2
  53. ------
  54. Step 1 will get you a .EXE, but you still need to run E2M to
  55. produce the .EXM file that will end up in the 95LX.  The E2M program
  56. relies on the .MAP file to deduce the data/code segment dividing point.
  57. If you don't already have it set, go into Options/Linker/Mapfile, and
  58. set it to Segments (if you have more map info in the file, that's okay,
  59. but Segments is needed at least).
  60.  
  61. Unfortunately for us, the output of Turbo Map files is not exactly
  62. compatible with the Microsoft format, so either you need to 1) Use the
  63. old E2M and massage the format to what is needed, or 2) write a small
  64. program that will do the massaging for you.
  65.  
  66. Here's how to do it manually:  load the .MAP file into the text editor
  67. of your choice.  Right below the Segment list, you need to insert a couple of
  68. lines of text that will give the DGROUP orgin (ie. beginning of all the data).
  69. The text must be exact--even spaces count.    Type in this:
  70.  Orgin   Group
  71.  xxxx:0  DGROUP
  72. where xxxx is the first four digits in the Start column of the Segment
  73. titled _DATA.  As an example, this is the .MAP file produces for BOXES,
  74. after we have modified it.
  75. ----------------------------
  76.  
  77.  Start  Stop   Length Name               Class
  78.  
  79.  00000H 01D70H 01D71H _TEXT              CODE
  80.  01D80H 024D1H 00752H _DATA              DATA
  81.  024E0H 02CDFH 00800H STACK              STACK
  82.  02CE0H 033E9H 0070AH _BSS               BSS
  83.  
  84.  Origin   Group
  85.  01D8:0   DGROUP
  86.  
  87. ----------------------------
  88. We looked up the segment named _DATA, and took the 01D8 (segment value)
  89. to put in this new information.  With this small modification to the .MAP
  90. file, the E2M program will convert your Turbo C .EXE without a snag.
  91. In theory, it shouldn't be too hard to whip up a program that adds this
  92. little bit of tag information to your map file, and just remember to run
  93. this before you run E2M.  Since the rest of the file beyond the "Origin"
  94. stuff isn't used by E2M, and since the segment info is not likely to change
  95. for a SysMgr app, you could cheat.  Your massager program could seek to
  96. the right position in the .MAP file to read out the segment (01D8), and
  97. seek past it to write this new little block (although it wouldn't be
  98. that much more work to read through the file and do a little parsing to
  99. find the _DATA line).
  100.  
  101. I would strongly suggest trying this out on a program that you know runs
  102. properly under the System Manager first before you start trying untested
  103. programs under TKERNEL or the 95LX.
  104.  
  105. For those of us who would much rather use Borland tools (present company
  106. included), this fix ought to make System Manager programming a little more
  107. palatable.
  108.  
  109.  
  110.